package ltd.rycloud.tms.controller;

import ltd.rycloud.tms.entity.User;
import ltd.rycloud.tms.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/***
 * @author     ：RYCloud.ltd ZhangLongBiao
 * @date       ：Created in 2019/6/24 1:54
 * @description：该控制类为用户的登录注册及用户增删改查权限设置操作类
 * @modified By：
 * @version: 1.0$
 *山东如翼云计算科技有限公司  张龙彪  15169994844
 ***/
@Controller
@RequestMapping("user")
public class RYCUserController {
    @Autowired
    IUserService userService;
    @RequestMapping("login")
    public String login(HttpServletRequest request, HttpSession session){
        String userName = request.getParameter("username");
        String pwd = request.getParameter("password");
        System.out.println(userName);
        System.out.println(pwd);
        User user1 = userService.login(userName,pwd);
        if (user1==null){
            return "login";
        }else{
            System.out.println(user1);
            session.setAttribute("user",user1);
        }
        return "index";
    }

}
